The dom destroy path is doing a dom_get on a non-existent domain to
authorshand@ubuntu.eng.hq.xensource.com <shand@ubuntu.eng.hq.xensource.com>
Wed, 14 Sep 2005 22:36:29 +0000 (14:36 -0800)
committershand@ubuntu.eng.hq.xensource.com <shand@ubuntu.eng.hq.xensource.com>
Wed, 14 Sep 2005 22:36:29 +0000 (14:36 -0800)
ensure it is non-existent.  This changes throws an explicit exception
when xc_domain_getinfo returns an error, instead of triggering an
internal python error.  It then handles the exception in dom_get by
returning None, which callers already expect to mean failure.

Signed-off-by: Robert Read <robert@xensource.com>
tools/python/xen/lowlevel/xc/xc.c
tools/python/xen/xend/XendDomainInfo.py

index 7f398978ebdebd2b6d9b3a0d8311969c10bb816c..c7c09efbc14bdba8cf008d589484032021398554 100644 (file)
@@ -220,6 +220,9 @@ static PyObject *pyxc_domain_getinfo(PyObject *self,
         return PyErr_NoMemory();
 
     nr_doms = xc_domain_getinfo(xc->xc_handle, first_dom, max_doms, info);
+
+    if (nr_doms < 0)
+        return PyErr_SetFromErrno(xc_error);
     
     list = PyList_New(nr_doms);
     for ( i = 0 ; i < nr_doms; i++ )
index 05edb93be2da5fd8720ec3f34353a7f631eba43b..b5929ce88b6eab5c5cc15c6b213c78b74bc3912b 100644 (file)
@@ -110,9 +110,13 @@ def dom_get(dom):
     @param dom: domain id
     @return: info or None
     """
-    domlist = xc.domain_getinfo(dom, 1)
-    if domlist and dom == domlist[0]['dom']:
-        return domlist[0]
+    try:
+        domlist = xc.domain_getinfo(dom, 1)
+        if domlist and dom == domlist[0]['dom']:
+            return domlist[0]
+    except Exception, err:
+        # ignore missing domain
+        log.exception("domain_getinfo(%d) failed, ignoring", dom)
     return None
 
 class XendDomainInfo: